home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 2: Applications / Linux Cubed Series 2 - Applications.iso / editors / emacs / emacs-19.000 / emacs-19 / usr / local / info / mh-e-2 < prev    next >
Encoding:
GNU Info File  |  1995-09-11  |  48.0 KB  |  1,180 lines

  1. This is Info file ../info/mh-e, produced by Makeinfo-1.55 from the
  2. input file mh-e.texi.
  3.  
  4.    This is Edition 1.1, last updated 26 April 1995, of `mh-e, The Emacs
  5. Interface to MH', for mh-e, Version 5.0.1.
  6.  
  7.    Copyright 1995 Free Software Foundation, Inc.
  8.  
  9.    Permission is granted to make and distribute verbatim copies of this
  10. manual provided the copyright notice and this permission notice are
  11. preserved on all copies.
  12.  
  13.    Permission is granted to copy and distribute modified versions of
  14. this manual under the conditions for verbatim copying, provided also
  15. that the section entitled "Copying" is included exactly as in the
  16. original, and provided that the entire resulting derived work is
  17. distributed under the terms of a permission notice identical to this
  18. one.
  19.  
  20.    Permission is granted to copy and distribute translations of this
  21. manual into another language, under the above conditions for modified
  22. versions, except that this permission notice may be stated in a
  23. translation approved by the Free Software Foundation.
  24.  
  25. 
  26. File: mh-e,  Node: Printing,  Next: Files and Pipes,  Prev: Organizing,  Up: Moving Mail
  27.  
  28. Printing Your Mail
  29. ------------------
  30.  
  31.    Printing mail is simple.  Enter `l' (`mh-print-msg') (for line
  32. printer or lpr).  The message is formatted with `mhl' and printed with
  33. the `lpr' command.  You can print all the messages in a sequence by
  34. specifying a prefix argument, in which case you are prompted for the
  35. name of the sequence (as in `C-u l frombob RET').
  36.  
  37. 
  38. File: mh-e,  Node: Files and Pipes,  Next: Finishing Up,  Prev: Printing,  Up: Moving Mail
  39.  
  40. Files and Pipes
  41. ---------------
  42.  
  43.    mh-e does offer a couple of commands that are not a part of MH.  The
  44. first one, `C-o' (`mh-write-msg-to-file'), writes a message to a file
  45. (think of the `o' as in "output").  You are prompted for the filename.
  46. If the file already exists, the message is appended to it.  You can
  47. also write the message to the file without the header by specifying a
  48. prefix argument (such as `C-u C-o /tmp/foobar RET').  Subsequent writes
  49. to the same file can be made with the `!' command.
  50.  
  51.    You can also pipe the message through a Unix shell command with the
  52. `|' (`mh-pipe-msg') command.  You are prompted for the Unix command
  53. through which you wish to run your message.  If you give an argument to
  54. this command, the message header is included in the text passed to the
  55. command (the contrived example `C-u | lpr' would be done with the `l'
  56. command instead).
  57.  
  58.    If the message is a shell archive `shar' or has been run through
  59. `uuencode' use `M-n' (`mh-store-msg') to extract the body of the
  60. message.  The default directory for extraction is the current
  61. directory, and you have a chance to specify a different extraction
  62. directory.  The next time you use this command, the default directory is
  63. the last directory you used.
  64.  
  65. 
  66. File: mh-e,  Node: Finishing Up,  Prev: Files and Pipes,  Up: Moving Mail
  67.  
  68. Finishing Up
  69. ------------
  70.  
  71.    If you've deleted a message or refiled it, but changed your mind, you
  72. can cancel the action before you've executed it.  Use `u' (`mh-undo')
  73. to undo a refile on or deletion of a single message.  You can also undo
  74. refiles and deletes for messages that belong to a given sequence by
  75. specifying a prefix argument.  You'll be prompted for the name of the
  76. sequence (as in `C-u u frombob RET').  Alternatively, you can use `M-u'
  77. (`mh-undo-folder') to undo all refiles or deletes in the current folder.
  78.  
  79.    If you've marked messages to be deleted or refiled and you want to go
  80. ahead and delete or refile the messages, use `x'
  81. (`mh-execute-commands').  Many mh-e commands that may affect the
  82. numbering of the messages (such as `M-r' or `M-p') will ask if you want
  83. to process refiles or deletes first and then either run `x' for you or
  84. undo the pending refiles and deletes, which are lost.
  85.  
  86.    When you want to quit using mh-e and go back to editing, you can use
  87. the `q' (`mh-quit') command.  This buries the buffers of the current
  88. mh-e folder and restores the buffers that were present when you first
  89. ran `M-x mh-rmail'.  You can later restore your mh-e session by
  90. selecting the `+inbox' buffer or by running `M-x mh-rmail' again.
  91.  
  92. 
  93. File: mh-e,  Node: Searching,  Next: Sequences,  Prev: Moving Mail,  Up: Using mh-e
  94.  
  95. Searching Through Messages
  96. ==========================
  97.  
  98.    You can search a folder for messages to or from a particular person
  99. or about a particular subject.  In fact, you can also search for
  100. messages containing selected strings in any arbitrary header field or
  101. any string found within the messages.  Use the `M-s'
  102. (`mh-search-folder') command.  You are first prompted for the name of
  103. the folder to search and then placed in the following buffer in MH-Pick
  104. mode:
  105.  
  106.      From: #
  107.      To:
  108.      Cc:
  109.      Date:
  110.      Subject:
  111.      --------
  112.      
  113.      
  114.      
  115.      
  116.      
  117.      
  118.      
  119.      
  120.      
  121.      --**-Emacs: pick-pattern    (MH-Pick)------All----------------------------
  122.      Pick window
  123.  
  124.    Edit this template by entering your search criteria in an appropriate
  125. header field that is already there, or create a new field yourself.  If
  126. the string you're looking for could be anywhere in a message, then place
  127. the string underneath the row of dashes.  The `M-s' command uses the MH
  128. command `pick' to do the real work, so read `pick'(1) to find out more
  129. about how to enter the criteria.
  130.  
  131.    There are no semantics associated with the search criteria--they are
  132. simply treated as strings.  Case is ignored when all lowercase is used,
  133. and regular expressions (a la `ed') are available.  It is all right to
  134. specify several search criteria.  What happens then is that a logical
  135. *and* of the various fields is performed.  If you prefer a logical *or*
  136. operation, run `M-s' multiple times.
  137.  
  138.    As an example, let's say that we want to find messages from Ginnean
  139. about horseback riding in the Kosciusko National Park (Australia) during
  140. January, 1994.  Normally we would start with a broad search and narrow
  141. it down if necessary to produce a manageable amount of data, but we'll
  142. cut to the chase and create a fairly restrictive set of criteria as
  143. follows:
  144.  
  145.      From: ginnean
  146.      To:
  147.      Cc:
  148.      Date: Jan 1994
  149.      Subject: horse.*kosciusko
  150.      --------
  151.  
  152.    As with MH-Letter mode, MH-Pick provides commands like `C-c C-f C-t'
  153. to help you fill in the blanks.
  154.  
  155. `C-c C-f C-t'
  156.      Move to `To:' header field (`mh-to-field').
  157.  
  158. `C-c C-f C-c'
  159.      Move to `cc:' header field (`mh-to-field').
  160.  
  161. `C-c C-f C-s'
  162.      Move to `Subject:' header field (`mh-to-field').
  163.  
  164. `C-c C-f C-f'
  165.      Move to `From:' header field (`mh-to-field').
  166.  
  167. `C-c C-f C-b'
  168.      Move to `Bcc:' header field (`mh-to-field').
  169.  
  170. `C-c C-f C-f'
  171.      Move to `Fcc:' header field (`mh-to-field').
  172.  
  173. `C-c C-f C-d'
  174.      Move to `Dcc:' header field (`mh-to-field').
  175.  
  176. `C-c C-c'
  177.      Execute the search (`mh-do-pick-search').
  178.  
  179.    To perform the search, type `C-c C-c' (`mh-do-pick-search').  The
  180. selected messages are placed in the search sequence, which you can use
  181. later in forwarding (*note Forwarding::.), printing (*note
  182. Printing::.), or narrowing your field of view (*note Sequences::.).
  183. Subsequent searches are appended to the search sequence.  If, however,
  184. you wish to start with a clean slate, first delete the search sequence
  185. (how to do this is discussed in *Note Sequences::).
  186.  
  187.    If you're searching in a folder that is already displayed in a
  188. MH-Folder buffer, only those messages contained in the buffer are used
  189. for the search.  Therefore, if you want to search in all messages,
  190. first kill the folder's buffer with `C-x k' or scan the entire folder
  191. with `M-r'.
  192.  
  193. 
  194. File: mh-e,  Node: Sequences,  Next: Miscellaneous,  Prev: Searching,  Up: Using mh-e
  195.  
  196. Using Sequences
  197. ===============
  198.  
  199.    For the whole scoop on MH sequences, refer to `mh-sequence'(5).  As
  200. you've read, several of the mh-e commands can operate on a sequence,
  201. which is a shorthand for a range or group of messages.  For example, you
  202. might want to forward several messages to a friend or colleague.  Here's
  203. how to manipulate sequences.
  204.  
  205. `%'
  206.      Put message in a sequence (`mh-put-msg-in-seq').
  207.  
  208. `?'
  209.      Display sequences that message belongs to (`mh-msg-is-in-seq').
  210.  
  211. `M-q'
  212.      List all sequences in folder (`mh-list-sequences').
  213.  
  214. `M-%'
  215.      Remove message from sequence (`mh-delete-msg-from-seq').
  216.  
  217. `M-#'
  218.      Delete sequence (`mh-delete-seq').
  219.  
  220. `C-x n'
  221.      Restrict display to messages in sequence (`mh-narrow-to-seq').
  222.  
  223. `C-x w'
  224.      Remove restriction; display all messages (`mh-widen').
  225.  
  226. `M-x mh-update-sequences'
  227.      Push mh-e's state out to MH.
  228.  
  229.    To place a message in a sequence, use `%' (`mh-put-msg-in-seq') to
  230. do it manually, or use the MH command `pick' or the mh-e version of
  231. `pick' (*Note Searching::) which create a sequence automatically.  Give
  232. `%' a prefix argument and you can add all the messages in one sequence
  233. to another sequence (for example, `C-u % SourceSequence RET').
  234.  
  235.    Once you've placed some messages in a sequence, you may wish to
  236. narrow the field of view to just those messages in the sequence you've
  237. created.  To do this, use `C-x n' (`mh-narrow-to-seq').  You are
  238. prompted for the name of the sequence.  What this does is show only
  239. those messages that are in the selected sequence in the MH-Folder
  240. buffer.  In addition, it limits further mh-e searches to just those
  241. messages.  When you want to widen the view to all your messages again,
  242. use `C-x w' (`mh-widen').
  243.  
  244.    You can see which sequences a message is in with the `?'
  245. (`mh-msg-is-in-seq') command.  Or, you can list all sequences in a
  246. selected folder (default is current folder) with `M-q'
  247. (`mh-list-sequences').
  248.  
  249.    If you want to remove a message from a sequence, use `M-%'
  250. (`mh-delete-msg-from-seq'), and if you want to delete an entire
  251. sequence, use `M-#' (`mh-delete-seq').  In the latter case you are
  252. prompted for the sequence to delete.  Note that this deletes only the
  253. sequence, not the messages in the sequence.  If you want to delete the
  254. messages, use `C-u d' (see *Note Deleting:: above).
  255.  
  256.    Two sequences are maintained internally by mh-e and pushed out to MH
  257. when you type either the `x' or `q' command.  They are the sequence
  258. specified by your `Unseen-Sequence:' profile entry and cur.  However,
  259. you can also just update MH's state with the command `M-x
  260. mh-update-sequences'.  See *Note Customizing Viewing:: for an example
  261. of how this command might be used.
  262.  
  263.    With the exceptions of `C-x n' and `C-x w', the underlying MH
  264. command dealing with sequences is `mark'.
  265.  
  266. 
  267. File: mh-e,  Node: Miscellaneous,  Prev: Sequences,  Up: Using mh-e
  268.  
  269. Miscellaneous Commands
  270. ======================
  271.  
  272.    One other command worth noting is `M-x mh-version'.  Since there
  273. were a few changes in command letters between Versions 3 and 4, use
  274. this command to see which version you are running.  This command didn't
  275. exist before Version 4, so the message `[No match]' indicates that it's
  276. time to upgrade (*note Getting mh-e::.).  In the meantime, use the
  277. older commands that are listed in *Note Changes to mh-e::.  The output
  278. of `M-x mh-version' should also be included with any bug report you
  279. send (*note Bug Reports::.).
  280.  
  281. 
  282. File: mh-e,  Node: Customizing mh-e,  Next: Odds and Ends,  Prev: Using mh-e,  Up: Top
  283.  
  284. Customizing mh-e
  285. ****************
  286.  
  287.    Until now, we've talked about the mh-e commands as they work "out of
  288. the box."  Of course, it is also possible to reconfigure mh-e beyond
  289. recognition.  The following sections describe all of the customization
  290. variables, show the defaults, and make recommendations for
  291. customization.  The outline of this chapter is identical to that of
  292. *Note Using mh-e::, to make it easier to find the variables you'd need
  293. to modify to affect a particular command.
  294.  
  295.    However, when customizing your mail environment, first try to change
  296. what you want in MH, and only change mh-e if changing MH is not
  297. possible.  That way you will get the same behavior inside and outside
  298. GNU Emacs.  Note that mh-e does not provide hooks for customizations
  299. that can be done in MH; this omission is intentional.
  300.  
  301.    Many string or integer variables are easy enough to modify using
  302. Emacs Lisp.  Any such modifications should be placed in a file called
  303. `.emacs' in your home directory (that is, `~/.emacs').  For example, to
  304. modify the variable that controls printing, you could add:
  305.  
  306.      (setq mh-lpr-command-format "nenscript -G -r -2 -i'%s'")
  307.  
  308.    *Note Customizing Printing:: talks more about this variable.
  309.  
  310.    Variables can also hold Boolean values.  In Emacs Lisp, the Boolean
  311. values are `nil', which means false, and `t', which means true.
  312. Usually, variables are turned off by setting their value to `nil', as in
  313.  
  314.      (setq mh-bury-show-buffer nil)
  315.  
  316.    which keeps the MH-Show buffer at the top of the buffer stack.  To
  317. turn a variable on, you use
  318.  
  319.      (setq mh-bury-show-buffer t)
  320.  
  321.    which places the MH-Show buffer at the bottom of the buffer stack.
  322. However, the text says to turn on a variable by setting it to a
  323. *non-`nil'* value, because sometimes values other than `t' are
  324. meaningful (for example, see `mhl-formfile', described in *Note
  325. Customizing Viewing::).  Other variables, such as hooks, involve a
  326. little more Emacs Lisp programming expertise.
  327.  
  328.    You can also "preview" the effects of changing variables before
  329. committing the changes to `~/.emacs'.  Variables can be changed in the
  330. current Emacs session by using `M-x set-variable'.
  331.  
  332.    In general, "commands" in this text refer to Emacs Lisp functions.
  333. Programs outside of Emacs are specifically called MH commands, shell
  334. commands, or Unix commands.
  335.  
  336.    I hope I've included enough examples here to get you well on your
  337. way.  If you want to explore Emacs Lisp further, a programming manual
  338. does exist, (1) and you can look at the code itself for examples.  Look
  339. in the Emacs Lisp directory on your system (such as
  340. `/usr/local/lib/emacs/lisp') and find all the `mh-*.el' files there.
  341. When calling mh-e and other Emacs Lisp functions directly from Emacs
  342. Lisp code, you'll need to know the correct arguments.  Use the online
  343. help for this.  For example, try `C-h f mh-execute-commands RET'.  If
  344. you write your own functions, please do not prefix your symbols
  345. (variables and functions) with `mh-'.  This prefix is reserved for the
  346. mh-e package.  To avoid conflicts with existing mh-e symbols, use a
  347. prefix like `my-' or your initials.
  348.  
  349. * Menu:
  350.  
  351. * Customizing Reading::
  352. * Customizing Sending::
  353. * Customizing Draft Editing::
  354. * Customizing Moving Mail::
  355. * Customizing Searching::
  356.  
  357.    ---------- Footnotes ----------
  358.  
  359.    (1)  Perhaps you can find the online version of *Note The GNU Emacs
  360. Lisp Reference Manual: (elisp)Top.  If not, you can order a printed
  361. manual, which has the desirable side-effect of helping to support the
  362. Free Software Foundation which made all this great software available.
  363. You can find an order form by running `C-h C-d', or you can request an
  364. order form from gnu@prep.ai.mit.edu.
  365.  
  366. 
  367. File: mh-e,  Node: Customizing Reading,  Next: Customizing Sending,  Prev: Customizing mh-e,  Up: Customizing mh-e
  368.  
  369. Reading Your Mail
  370. =================
  371.  
  372.    I'll start out by including a function that I use as a front end to
  373. mh-e.  (1) It toggles between your working window configuration, which
  374. may be quite involved--windows filled with source, compilation output,
  375. man pages, and other documentation--and your mh-e window configuration.
  376. Like the rest of the customization described in this chapter, simply
  377. add the following code to `~/.emacs'.  Don't be intimidated by the size
  378. of this example; most customizations are only one line.
  379.  
  380.      Starting mh-e
  381.      
  382.      (defvar my-mh-screen-saved nil
  383.        "Set to non-`nil' when mh-e window configuration shown.")
  384.      (defvar my-normal-screen nil "Normal window configuration.")
  385.      (defvar my-mh-screen nil "mh-e window configuration.")
  386.      
  387.      (defun my-mh-rmail (&optional arg)
  388.        "Toggle between mh-e and normal screen configurations.
  389.      With non-`nil' or prefix argument, inc mailbox as well
  390.      when going into mail."
  391.        (interactive "P")                 ; user callable function, P=prefix arg
  392.        (setq my-mh-screen-saved          ; save state
  393.              (cond
  394.               ;; Bring up mh-e screen if arg or normal window configuration.
  395.               ;; If arg or +inbox buffer doesn't exist, run mh-rmail.
  396.               ((or arg (null my-mh-screen-saved))
  397.                (setq my-normal-screen (current-window-configuration))
  398.                (if (or arg (null (get-buffer "+inbox")))
  399.                    (mh-rmail)
  400.                  (set-window-configuration my-mh-screen))
  401.                t)                        ; set my-mh-screen-saved to `t'
  402.               ;; Otherwise, save mh-e screen and restore normal screen.
  403.               (t
  404.                (setq my-mh-screen (current-window-configuration))
  405.                (set-window-configuration my-normal-screen)
  406.                nil))))                   ; set my-mh-screen-saved to nil
  407.      
  408.      (global-set-key "\C-x\r" 'my-mh-rmail)  ; call with C-x RET
  409.  
  410.    If you type an argument (`C-u') or if `my-mh-screen-saved' is `nil'
  411. (meaning a non-mh-e window configuration), the current window
  412. configuration is saved, either +inbox is displayed or `mh-rmail' is
  413. run, and the mh-e window configuration is shown.  Otherwise, the mh-e
  414. window configuration is saved and the original configuration is
  415. displayed.
  416.  
  417.    Now to configure mh-e.  The following table lists general mh-e
  418. variables and variables that are used while reading mail.
  419.  
  420. `mh-progs'
  421.      Directory containing MH programs (default: dynamic).
  422.  
  423. `mh-lib'
  424.      Directory containing MH support files and programs (default:
  425.      dynamic).
  426.  
  427. `mh-do-not-confirm'
  428.      Don't confirm on non-reversible commands (default: `nil').
  429.  
  430. `mh-summary-height'
  431.      Number of scan lines to show (includes mode line) (default: 4).
  432.  
  433. `mh-folder-mode-hook'
  434.      Functions to run in MH-Folder mode (default: `nil').
  435.  
  436. `mh-clean-message-header'
  437.      Remove extraneous headers (default: `nil').
  438.  
  439. `mh-invisible-headers'
  440.      Headers to hide (default: `"^Received: \\| ^Message-Id: \\|
  441.      ^Remailed-\\| ^Via: \\| ^Mail-from: \\| ^Return-Path: \\|
  442.      ^In-Reply-To: \\| ^Resent-"').
  443.  
  444. `mh-visible-headers'
  445.      Headers to display (default: `nil').
  446.  
  447. `mhl-formfile'
  448.      Format file for `mhl' (default: `nil').
  449.  
  450. `mh-show-hook'
  451.      Functions to run when showing message (default: `nil').
  452.  
  453. `mh-show-mode-hook'
  454.      Functions to run when showing message (default: `nil').
  455.  
  456. `mh-bury-show-buffer'
  457.      Leave show buffer at bottom of stack (default: `t').
  458.  
  459. `mh-show-buffer-mode-line-buffer-id'
  460.      Name of show buffer in mode line (default: `"{show-%s} %d"').
  461.  
  462.    The two variables `mh-progs' and `mh-lib' are used to tell mh-e
  463. where the MH programs and supporting files are kept, respectively.
  464. mh-e does try to figure out where they are kept for itself by looking in
  465. common places and in the user's `PATH' environment variable, but if it
  466. cannot find the directories, or finds the wrong ones, you should set
  467. these variables.  The name of the directory should be placed in double
  468. quotes, and there should be a trailing slash (`/').  See the example in
  469. *Note Getting Started::.
  470.  
  471.    If you never make mistakes, and you do not like confirmations for
  472. your actions, you can set `mh-do-not-confirm' to a non-`nil' value to
  473. disable confirmation for unrecoverable commands such as `M-k'
  474. (`mh-kill-folder') and `M-u' (`mh-undo-folder').  Here's how you set
  475. boolean values:
  476.  
  477.      (setq mh-do-not-confirm t)
  478.  
  479.    The variable `mh-summary-height' controls the number of scan lines
  480. displayed in the MH-Folder window, including the mode line.  The
  481. default value of 4 means that 3 scan lines are displayed.  Here's how
  482. you set numerical values:
  483.  
  484.      (setq mh-summary-height 2)              ; only show the current scan line
  485.  
  486.    Normally the buffer for displaying messages is buried at the bottom
  487. at the buffer stack.  You may wish to disable this feature by setting
  488. `mh-bury-show-buffer' to `nil'.  One advantage of not burying the show
  489. buffer is that one can delete the show buffer more easily in an
  490. electric buffer list because of its proximity to its associated
  491. MH-Folder buffer.  Try running `M-x electric-buffer-list' to see what I
  492. mean.
  493.  
  494.    The hook `mh-folder-mode-hook' is called when a new folder is
  495. created with MH-Folder mode.  This could be used to set your own key
  496. bindings, for example:
  497.  
  498.      Create additional key bindings via mh-folder-mode-hook
  499.      
  500.      (defvar my-mh-init-done nil "Non-`nil' when one-time mh-e settings made.")
  501.      
  502.      (defun my-mh-folder-mode-hook ()
  503.        "Hook to set key bindings in MH-Folder mode."
  504.        (if (not my-mh-init-done)             ; only need to bind the keys once 
  505.            (progn
  506.              (local-set-key "/" 'search-msg)
  507.              (local-set-key "b" 'mh-burst-digest)    ; better use of `b'
  508.              (setq my-mh-init-done t))))
  509.      
  510.      ;;; Emacs 19
  511.      (add-hook 'mh-folder-mode-hook 'my-mh-folder-mode-hook)
  512.      ;;; Emacs 18
  513.      ;;;   (setq mh-folder-mode-hook (cons 'my-mh-folder-mode-hook
  514.      ;;;                               mh-folder-mode-hook))
  515.      
  516.      (defun search-msg ()
  517.        "Search for a regexp in the current message."
  518.        (interactive)                         ; user function
  519.        (save-window-excursion
  520.          (other-window 1)                    ; go to next window
  521.          (isearch-forward-regexp)))          ; string search; hit return (ESC
  522.                                              ;   in Emacs 18) when done
  523.  
  524. * Menu:
  525.  
  526. * Customizing Viewing::
  527. * Customizing Moving Around::
  528.  
  529.    ---------- Footnotes ----------
  530.  
  531.    (1)  Stephen Gildea's favorite binding is `(global-set-key "\C-cr"
  532. 'mh-rmail)'.
  533.  
  534. 
  535. File: mh-e,  Node: Customizing Viewing,  Next: Customizing Moving Around,  Prev: Customizing Reading,  Up: Customizing Reading
  536.  
  537. Viewing Your Mail
  538. -----------------
  539.  
  540.    Several variables control what displayed messages look like.
  541. Normally messages are delivered with a handful of uninteresting header
  542. fields.  You can make them go away by setting `mh-clean-message-header'
  543. to a non-`nil' value.  The header can then be cleaned up in two ways.
  544. By default, the header fields in `mh-invisible-headers' are removed.
  545. On the other hand, you could set `mh-visible-headers' to the fields
  546. that you would like to see.  If this variable is set,
  547. `mh-invisible-headers' is ignored.  I suggest that you not set
  548. `mh-visible-headers' since if you use this variable, you might miss a
  549. lot of header fields that you'd rather not miss.  As an example of how
  550. to set a string variable, `mh-visible-headers' can be set to show a
  551. minimum set of header fields (see (*Note Syntax of Regular Expressions:
  552. (emacs)Regexps, for a description of the special characters in this
  553. string):
  554.  
  555.      (setq mh-visible-headers "^From: \\|^Subject: \\|^Date: ")
  556.  
  557.    Normally mh-e takes care of displaying messages itself (rather than
  558. calling an MH program to do the work).  If you'd rather have `mhl'
  559. display the message (within mh-e), set the variable `mhl-formfile' to a
  560. non-`nil' value.  You can set this variable either to `t' to use the
  561. default format file or to a filename if you have your own format file
  562. (`mhl'(1) tells you how to write one).  When writing your own format
  563. file, use a nonzero value for `overflowoffset' to ensure the header is
  564. RFC 822 compliant and parseable by mh-e.  `mhl' is always used for
  565. printing and forwarding; in this case, the value of `mhl-formfile' is
  566. consulted if it is a filename.
  567.  
  568.    Two hooks can be used to control how messages are displayed.  The
  569. first hook, `mh-show-mode-hook', is called early on in the process of
  570. displaying of messages.  It is used to perform some actions on the
  571. contents of messages, such as highlighting the header fields.  If you're
  572. running Emacs 19 under the X Window System, the following example will
  573. highlight the `From:' and `Subject:' header fields.  This is a very
  574. nice feature indeed.
  575.  
  576.      Emphasize header fields in different fonts via mh-show-mode-hook
  577.      
  578.      (defvar my-mh-keywords
  579.         '(("^From: \\(.*\\)" 1 'bold t)
  580.           ("^Subject: \\(.*\\)" 1 'highlight t))
  581.        "mh-e additions for font-lock-keywords.")
  582.      
  583.      (defun my-mh-show-mode-hook ()
  584.        "Hook to turn on and customize fonts."
  585.        (require 'font-lock)                 ; for font-lock-keywords below
  586.        (make-local-variable 'font-lock-mode-hook) ; don't affect other buffers
  587.        (add-hook 'font-lock-mode-hook       ; set a hook with inline function
  588.                  (function                  ; modifies font-lock-keywords when
  589.                   (lambda ()                ; font-lock-mode run
  590.                     (setq font-lock-keywords
  591.                           (append my-mh-keywords font-lock-keywords)))))
  592.        (font-lock-mode 1))                  ; change the typefaces
  593.      
  594.      (if window-system                      ; can't do this on ASCII terminal
  595.          (add-hook 'mh-show-mode-hook 'my-mh-show-mode-hook))
  596.  
  597.    The second hook, `mh-show-hook', is the last thing called after
  598. messages are displayed.  It's used to affect the behavior of mh-e in
  599. general or when `mh-show-mode-hook' is too early.  For example, if you
  600. wanted to keep mh-e in sync with MH, you could use `mh-show-hook' as
  601. follows:
  602.  
  603.      (add-hook 'mh-show-hook 'mh-update-sequences)
  604.  
  605.    The function `mh-update-sequences' is documented in *Note Finishing
  606. Up::.  For those who like to modify their mode lines, use
  607. `mh-show-buffer-mode-line-buffer-id' to modify the mode line in the
  608. MH-Show buffers.  Place the two escape strings `%s' and `%d', which
  609. will display the folder name and the message number, respectively,
  610. somewhere in the string in that order.  The default value of
  611. `"{show-%s} %d"' yields a mode line of
  612.  
  613.      -----{show-+inbox} 4      (MH-Show)--Bot----------------------------------
  614.  
  615. 
  616. File: mh-e,  Node: Customizing Moving Around,  Prev: Customizing Viewing,  Up: Customizing Reading
  617.  
  618. Moving Around
  619. -------------
  620.  
  621.    When you use `t' (`mh-toggle-showing') to toggle between show mode
  622. and scan mode, the MH-Show buffer is hidden and the MH-Folder buffer is
  623. left alone.  Setting `mh-recenter-summary-p' to a non-`nil' value
  624. causes the toggle to display as many scan lines as possible, with the
  625. cursor at the middle.  The effect of `mh-recenter-summary-p' is rather
  626. useful, but it can be annoying on a slow network connection.
  627.  
  628. 
  629. File: mh-e,  Node: Customizing Sending,  Next: Customizing Draft Editing,  Prev: Customizing Reading,  Up: Customizing mh-e
  630.  
  631. Sending Mail
  632. ============
  633.  
  634.    You may wish to start off by adding the following useful key
  635. bindings to your `.emacs' file:
  636.  
  637.      (global-set-key "\C-xm" 'mh-smail)
  638.      (global-set-key "\C-x4m" 'mh-smail-other-window)
  639.  
  640.    In addition, several variables are useful when sending mail or
  641. replying to mail.  They are summarized in the following table.
  642.  
  643. `mh-comp-formfile'
  644.      Format file for drafts (default: `"components"').
  645.  
  646. `mh-repl-formfile'
  647.      Format file for replies (default: `"replcomps"').
  648.  
  649. `mh-letter-mode-hook'
  650.      Functions to run in MH-Letter mode (default: `nil').
  651.  
  652. `mh-compose-letter-function'
  653.      Functions to run when starting a new draft (default: `nil').
  654.  
  655. `mh-reply-default-reply-to'
  656.      Whom reply goes to (default: `nil').
  657.  
  658. `mh-forward-subject-format'
  659.      Format string for forwarded message subject (default: `"%s: %s"').
  660.  
  661. `mh-redist-full-contents'
  662.      `send' requires entire message (default: `nil').
  663.  
  664. `mh-new-draft-cleaned-headers'
  665.      Remove these header fields from re-edited draft (default:
  666.      `"^Date:\\| ^Received:\\| ^Message-Id:\\| ^From:\\| ^Sender:\\|
  667.      ^Delivery-Date:\\| ^Return-Path:"').
  668.  
  669.    Since mh-e does not use `comp' to create the initial draft, you need
  670. to set `mh-comp-formfile' to the name of your components file if it
  671. isn't `components'.  This is the name of the file that contains the
  672. form for composing messages.  If it does not contain an absolute
  673. pathname, mh-e searches for the file first in your MH directory and
  674. then in the system MH library directory (such as `/usr/local/lib/mh').
  675. Replies, on the other hand, are built using `repl'.  You can change the
  676. location of the field file from the default of `replcomps' by modifying
  677. `mh-repl-formfile'.
  678.  
  679.    Two hooks are provided to run commands on your freshly created draft.
  680. The first hook, `mh-letter-mode-hook', allows you to do some processing
  681. before editing a letter.  For example, you may wish to modify the
  682. header after `repl' has done its work, or you may have a complicated
  683. `components' file and need to tell mh-e where the cursor should go.
  684. Here's an example of how you would use this hook--all of the other
  685. hooks are set in this fashion as well.
  686.  
  687.      Prepare draft for editing via mh-letter-mode-hook
  688.      
  689.      (defvar letter-mode-init-done nil
  690.        "Non-`nil' when one-time mh-e settings have made.")
  691.      
  692.      (defun my-mh-letter-mode-hook ()
  693.        "Hook to prepare letter for editing."
  694.        (if (not letter-mode-init-done)    ; only need to bind the keys once
  695.            (progn
  696.              (local-set-key "\C-ctb" 'add-enriched-text)
  697.              (local-set-key "\C-cti" 'add-enriched-text)
  698.              (local-set-key "\C-ctf" 'add-enriched-text)
  699.              (local-set-key "\C-cts" 'add-enriched-text)
  700.              (local-set-key "\C-ctB" 'add-enriched-text)
  701.              (local-set-key "\C-ctu" 'add-enriched-text)
  702.              (local-set-key "\C-ctc" 'add-enriched-text)
  703.              (setq letter-mode-init-done t)))
  704.        (setq fill-prefix "  ")            ; I find indented text easier to read
  705.        (save-excursion
  706.          (goto-char (point-max))          ; go to end of message to
  707.          (mh-insert-signature)))          ;   insert signature
  708.      
  709.      (add-hook 'mh-letter-mode-hook 'my-mh-letter-mode-hook)
  710.  
  711.    The function, `add-enriched-text' is defined in the example in *Note
  712. Customizing Editing MIME::.
  713.  
  714.    The second hook, a function really, is `mh-compose-letter-function'.
  715. Like `mh-letter-mode-hook', it is called just before editing a new
  716. message; however, it is the last function called before you edit your
  717. message.  The consequence of this is that you can write a function to
  718. write and send the message for you.  This function is passed three
  719. arguments: the contents of the `To:', `Subject:', and `cc:' header
  720. fields.
  721.  
  722. * Menu:
  723.  
  724. * Customizing Replying::
  725. * Customizing Forwarding::
  726. * Customizing Redistributing::
  727. * Customizing Old Drafts::
  728.  
  729. 
  730. File: mh-e,  Node: Customizing Replying,  Next: Customizing Forwarding,  Prev: Customizing Sending,  Up: Customizing Sending
  731.  
  732. Replying to Mail
  733. ----------------
  734.  
  735.    If you find that most of the time that you specify `cc' when you
  736. reply to a message, set `mh-reply-default-reply-to' to `cc'.  This
  737. variable is normally set to `nil' so that you are prompted for the
  738. recipient of a reply.  It can be set to one of `from', `to', or `cc';
  739. you are then no longer prompted for the recipient(s) of your reply.
  740.  
  741. 
  742. File: mh-e,  Node: Customizing Forwarding,  Next: Customizing Redistributing,  Prev: Customizing Replying,  Up: Customizing Sending
  743.  
  744. Forwarding Mail
  745. ---------------
  746.  
  747.    When forwarding a message, the format of the `Subject:' header field
  748. can be modified by the variable `mh-forward-subject-format'.  This
  749. variable is a string which includes two escapes (`%s').  The first `%s'
  750. is replaced with the sender of the original message, and the second one
  751. is replaced with the original `Subject:'.  The default value of `"%s:
  752. %s"' takes a message with the header:
  753.  
  754.      To: Bill Wohler <wohler@newt.com>
  755.      Subject: Re: 49er football
  756.      From: Greg DesBrisay <gd@cellnet.com>
  757.  
  758.    and creates a subject header field of:
  759.  
  760.      Subject: Greg DesBrisay: Re: 49er football
  761.  
  762. 
  763. File: mh-e,  Node: Customizing Redistributing,  Next: Customizing Old Drafts,  Prev: Customizing Forwarding,  Up: Customizing Sending
  764.  
  765. Redistributing Your Mail
  766. ------------------------
  767.  
  768.    The variable `mh-redist-full-contents' must be set to non-`nil' if
  769. `dist' requires the whole letter for redistribution, which is the case
  770. if `send' is compiled with the BERK (1)  option (which many people
  771. abhor).  If you find that MH will not allow you to redistribute a
  772. message that has been redistributed before, this variable should be set
  773. to `nil'.
  774.  
  775.    ---------- Footnotes ----------
  776.  
  777.    (1)  To see which options your copy of MH was compiled with, use
  778. `M-x mh-version' (*Note Miscellaneous::).
  779.  
  780. 
  781. File: mh-e,  Node: Customizing Old Drafts,  Prev: Customizing Redistributing,  Up: Customizing Sending
  782.  
  783. Editing Old Drafts and Bounced Messages
  784. ---------------------------------------
  785.  
  786.    The header fields specified by `mh-new-draft-cleaned-headers' are
  787. removed from an old draft that has been recreated with `M-e'
  788. (`mh-extract-rejected-mail') or `M-a' (`mh-edit-again').  If when you
  789. edit an old draft with these commands you find that there are header
  790. fields that you don't want included, you can append them to this
  791. variable.  For example,
  792.  
  793.      (setq mh-new-draft-cleaned-headers
  794.            (concat mh-new-draft-cleaned-headers "\\|^Some-Field:"))
  795.  
  796.    This appends the regular expression `\\|^Some-Field:' to the
  797. variable (*note Syntax of Regular Expressions: (emacs)Regexps.).  The
  798. `\\|' means *or*, and the `^' (caret) matches the beginning of the
  799. line.  This is done to be very specific about which fields match.  The
  800. literal `:' is appended for the same reason.
  801.  
  802. 
  803. File: mh-e,  Node: Customizing Draft Editing,  Next: Customizing Moving Mail,  Prev: Customizing Sending,  Up: Customizing mh-e
  804.  
  805. Editing a Draft
  806. ===============
  807.  
  808.    There are several variables used during the draft editing phase.
  809. Examples include changing the name of the file that holds your signature
  810. or telling mh-e about new multimedia types.  They are:
  811.  
  812. `mh-yank-from-start-of-msg'
  813.      How to yank when region not set (default: `t').
  814.  
  815. `mh-ins-buf-prefix'
  816.      Indent for yanked messages (default: `"> "').
  817.  
  818. `mail-citation-hook'
  819.      Functions to run on yanked messages (default: `nil').
  820.  
  821. `mh-delete-yanked-msg-window'
  822.      Delete message window on yank (default: `nil').
  823.  
  824. `mh-mime-content-types'
  825.      List of valid content types (default: `'(("text/plain")
  826.      ("text/richtext") ("multipart/mixed") ("multipart/alternative")
  827.      ("multipart/digest") ("multipart/parallel") ("message/rfc822")
  828.      ("message/partial") ("message/external-body")
  829.      ("application/octet-stream") ("application/postscript")
  830.      ("image/jpeg") ("image/gif") ("audio/basic") ("video/mpeg"))').
  831.  
  832. `mh-mhn-args'
  833.      Additional arguments for `mhn' (default: `nil').
  834.  
  835. `mh-signature-file-name'
  836.      File containing signature (default: `"~/.signature"').
  837.  
  838. `mh-before-send-letter-hook'
  839.      Functions to run before sending draft (default: `nil').
  840.  
  841. `mh-send-prog'
  842.      MH program used to send messages (default: `"send"').
  843.  
  844. * Menu:
  845.  
  846. * Customizing Editing Textual::
  847. * Customizing Editing MIME::
  848. * Customizing Sending Message::
  849.  
  850. 
  851. File: mh-e,  Node: Customizing Editing Textual,  Next: Customizing Editing MIME,  Prev: Customizing Draft Editing,  Up: Customizing Draft Editing
  852.  
  853. Editing Textual Messages
  854. ------------------------
  855.  
  856.    The following two sections include variables that customize the way
  857. you edit a draft.  The discussion here applies to editing multimedia
  858. messages as well.
  859.  
  860. * Menu:
  861.  
  862. * Customizing Inserting Letter::
  863. * Customizing Signature::
  864.  
  865. 
  866. File: mh-e,  Node: Customizing Inserting Letter,  Next: Customizing Signature,  Prev: Customizing Editing Textual,  Up: Customizing Editing Textual
  867.  
  868. Inserting letter to which you're replying
  869. .........................................
  870.  
  871.    To control how much of the message to which you are replying is
  872. yanked by `C-c C-y' (`mh-yank-cur-msg') into your reply, modify
  873. `mh-yank-from-start-of-msg'.  The default value of `t' means that the
  874. entire message is copied.  If it is set to `'body' (don't forget the
  875. apostrophe), then only the message body is copied.  If it is set to
  876. `nil', only the part of the message following point (the current cursor
  877. position in the message's buffer) is copied.  In any case, this
  878. variable is ignored if a region is set in the message you are replying
  879. to.  The string contained in `mh-ins-buf-prefix' is inserted before
  880. each line of a message that is inserted into a draft with `C-c C-y'
  881. (`mh-yank-cur-msg').  I suggest that you not modify this variable.  The
  882. default value of `"> "' is the default string for many mailers and news
  883. readers: messages are far easier to read if several included messages
  884. have all been indented by the same string.  The variable
  885. `mail-citation-hook' is `nil' by default, which means that when a
  886. message is inserted into the letter, each line is prefixed by
  887. `mh-ins-buf-prefix'.  Otherwise, it can be set to a function that
  888. modifies an included citation.  (1) If you like to yank all the text
  889. from the message you're replying to in one go, set
  890. `mh-delete-yanked-msg-window' to non-`nil' to delete the window
  891. containing the original message after yanking it to make more room on
  892. your screen for your reply.
  893.  
  894.    ---------- Footnotes ----------
  895.  
  896.    (1)  *Supercite* is an example of a full-bodied, full-featured
  897. citation package.  It is in Emacs versions 19.15 and later, and can be
  898. found via anonymous `ftp' on `archive.cis.ohio-state.edu' in
  899. `/pub/gnu/emacs/elisp-archive/packages/sc3.1.tar.Z'
  900.  
  901. 
  902. File: mh-e,  Node: Customizing Signature,  Prev: Customizing Inserting Letter,  Up: Customizing Editing Textual
  903.  
  904. Inserting your signature
  905. ........................
  906.  
  907.    You can change the name of the file inserted with `C-c C-s'
  908. (`mh-insert-signature') by changing `mh-signature-file-name' (default:
  909. `"~/.signature"').
  910.  
  911. 
  912. File: mh-e,  Node: Customizing Editing MIME,  Next: Customizing Sending Message,  Prev: Customizing Editing Textual,  Up: Customizing Draft Editing
  913.  
  914. Editing Multimedia Messages
  915. ---------------------------
  916.  
  917.    The variable `mh-mime-content-types' contains a list of the
  918. currently valid content types.  They are listed in the table in *Note
  919. Customizing Draft Editing::.  If you encounter a new content type, you
  920. can add it like this:
  921.  
  922.      (setq mh-mime-content-types (append mh-mime-content-types
  923.                                          '(("NEW/TYPE"))))
  924.  
  925.    Emacs macros can be used to insert enriched text directives like
  926. `<bold>'.  The following code will make, for example, `C-c t b' insert
  927. the `<bold>' directive.
  928.  
  929.      Emacs macros for entering enriched text
  930.      
  931.      (defvar enriched-text-types '(("b" . "bold") ("i" . "italic") ("f" . "fixed")
  932.                                    ("s" . "smaller") ("B" . "bigger")
  933.                                    ("u" . "underline") ("c" . "center"))
  934.        "Alist of (final-character . directive) choices for add-enriched-text.
  935.      Additional types can be found in RFC 1563.")
  936.      
  937.      (defun add-enriched-text (begin end)
  938.        "Add enriched text directives around region.
  939.      The directive used comes from the list enriched-text-types and is
  940.      specified by the last keystroke of the command.  When called from Lisp,
  941.      arguments are BEGIN and END."
  942.        (interactive "r")
  943.        ;; Set type to the directive indicated by the last keystroke.
  944.        (let ((type (cdr (assoc (char-to-string (logior last-input-char ?`))
  945.                                enriched-text-types))))
  946.          (save-restriction              ; restores state from narrow-to-region
  947.            (narrow-to-region begin end) ; narrow view to region
  948.            (goto-char (point-min))      ; move to beginning of text
  949.            (insert "<" type ">")        ; insert beginning directive
  950.            (goto-char (point-max))      ; move to end of text
  951.            (insert "</" type ">"))))    ; insert terminating directive
  952.  
  953.    To use the function `add-enriched-text', first create keybindings
  954. for it (*note Customizing Sending::.).  Then, set the mark with `C-@'
  955. or `C-SPC', type in the text to be highlighted, and type `C-c t b'.
  956. This adds `<bold>' where you set the mark and adds `</bold>' at the
  957. location of your cursor, giving you something like: `You should be
  958. <bold>very</bold>'.  You may also be interested in investigating
  959. `sgml-mode'.
  960.  
  961. * Menu:
  962.  
  963. * Customizing Sending MIME::
  964.  
  965. 
  966. File: mh-e,  Node: Customizing Sending MIME,  Prev: Customizing Editing MIME,  Up: Customizing Editing MIME
  967.  
  968. Readying multimedia messages for sending
  969. ........................................
  970.  
  971.    If you wish to pass additional arguments to `mhn' to affect how it
  972. builds your message, use the variable `mh-mhn-args'.  For example, you
  973. can build a consistency check into the message by setting `mh-mhn-args'
  974. to `-check'.  The recipient of your message can then run `mhn -check'
  975. on the message--`mhn' will complain if the message has been corrupted
  976. on the way.  The `C-c C-e' (`mh-mhn-edit') command only consults this
  977. variable when given a prefix argument.
  978.  
  979. 
  980. File: mh-e,  Node: Customizing Sending Message,  Prev: Customizing Editing MIME,  Up: Customizing Draft Editing
  981.  
  982. Sending a Message
  983. -----------------
  984.  
  985.    If you want to check your spelling in your message before sending,
  986. use `mh-before-send-letter-hook' like this:
  987.  
  988.    Spell-check message via mh-before-send-letter-hook
  989.  
  990.      (add-hook 'mh-before-send-letter-hook 'ispell-message)
  991.  
  992.    In case the MH `send' program is installed under a different name,
  993. use `mh-send-prog' to tell mh-e the name.
  994.  
  995. 
  996. File: mh-e,  Node: Customizing Moving Mail,  Next: Customizing Searching,  Prev: Customizing Draft Editing,  Up: Customizing mh-e
  997.  
  998. Moving Your Mail Around
  999. =======================
  1000.  
  1001.    If you change the name of some of the MH programs or have your own
  1002. printing programs, the following variables can help you.  They are
  1003. described in detail in the subsequent sections.
  1004.  
  1005. `mh-inc-prog'
  1006.      Program to incorporate mail (default: `"inc"').
  1007.  
  1008. `mh-inc-folder-hook'
  1009.      Functions to run when incorporating mail (default: `nil').
  1010.  
  1011. `mh-delete-msg-hook'
  1012.      Functions to run when deleting messages (default: `nil').
  1013.  
  1014. `mh-print-background'
  1015.      Print in foreground or background (default: `nil').
  1016.  
  1017. `mh-lpr-command-format'
  1018.      Command used to print (default: `"lpr -J '%s'"').
  1019.  
  1020. `mh-default-folder-for-message-function'
  1021.      Function to generate a default folder (default: `nil').
  1022.  
  1023. `mh-auto-folder-collect'
  1024.      Collect folder names in background at startup (default: `t').
  1025.  
  1026. `mh-recursive-folders'
  1027.      Collect nested folders (default: `nil').
  1028.  
  1029. `mh-refile-msg-hook'
  1030.      Functions to run when refiling message (default: `nil').
  1031.  
  1032. `mh-store-default-directory'
  1033.      Default directory for storing files created by `uuencode' or `shar'
  1034.      (default: `nil').
  1035.  
  1036. `mh-sortm-args'
  1037.      Additional arguments for `sortm' (default: `nil').
  1038.  
  1039. `mh-scan-prog'
  1040.      Program to scan messages (default: `"scan"').
  1041.  
  1042. `mh-before-quit-hook'
  1043.      Functions to run before quitting (default: `nil').  See also
  1044.      `mh-quit-hook'.
  1045.  
  1046. `mh-quit-hook'
  1047.      Functions to run after quitting (default: `nil'). See also
  1048.      `mh-before-quit-hook'.
  1049.  
  1050. * Menu:
  1051.  
  1052. * Customizing Incorporating::
  1053. * Customizing Deleting::
  1054. * Customizing Organizing::
  1055. * Customizing Printing::
  1056. * Customizing Files and Pipes::
  1057. * Customizing Finishing Up::
  1058.  
  1059. 
  1060. File: mh-e,  Node: Customizing Incorporating,  Next: Customizing Deleting,  Prev: Customizing Moving Mail,  Up: Customizing Moving Mail
  1061.  
  1062. Incorporating Your Mail
  1063. -----------------------
  1064.  
  1065.    The name of the program that incorporates new mail is stored in
  1066. `mh-inc-prog'; it is `"inc"' by default.  This program generates a
  1067. one-line summary for each of the new messages.  Unless it is an
  1068. absolute pathname, the file is assumed to be in the `mh-progs'
  1069. directory.  You may also link a file to `inc' that uses a different
  1070. format (see `mh-profile'(5)).  You'll then need to modify several
  1071. variables appropriately; see `mh-scan-prog' below.  You can set the
  1072. hook `mh-inc-folder-hook', which is called after new mail is
  1073. incorporated by the `i' (`mh-inc-folder') command.  A good use of this
  1074. hook is to rescan the whole folder either after running `M-x mh-rmail'
  1075. the first time or when you've changed the message numbers from outside
  1076. of mh-e.
  1077.  
  1078.      Rescan folder after incorporating new mail via mh-inc-folder-hook
  1079.      
  1080.      (defun my-mh-inc-folder-hook ()
  1081.        "Hook to rescan folder after incorporating mail."
  1082.        (if (buffer-modified-p)            ; if outstanding refiles and deletes,
  1083.            (mh-execute-commands))         ;   carry them out
  1084.        (mh-rescan-folder)                 ; synchronize with +inbox
  1085.        (mh-show))                         ; show the current message
  1086.      
  1087.      (add-hook 'mh-inc-folder-hook 'my-mh-inc-folder-hook)
  1088.  
  1089. 
  1090. File: mh-e,  Node: Customizing Deleting,  Next: Customizing Organizing,  Prev: Customizing Incorporating,  Up: Customizing Moving Mail
  1091.  
  1092. Deleting Your Mail
  1093. ------------------
  1094.  
  1095.    The hook `mh-delete-msg-hook' is called after you mark a message for
  1096. deletion.  For example, the current maintainer of mh-e used this once
  1097. when he kept statistics on his mail usage.
  1098.  
  1099. 
  1100. File: mh-e,  Node: Customizing Organizing,  Next: Customizing Printing,  Prev: Customizing Deleting,  Up: Customizing Moving Mail
  1101.  
  1102. Organizing Your Mail with Folders
  1103. ---------------------------------
  1104.  
  1105.    By default, operations on folders work only one level at a time.  Set
  1106. `mh-recursive-folders' to non-`nil' to operate on all folders.  This
  1107. mostly means that you'll be able to see all your folders when you press
  1108. TAB when prompted for a folder name.  The variable
  1109. `mh-auto-folder-collect' is normally turned on to generate a list of
  1110. folder names in the background as soon as mh-e is loaded.  Otherwise,
  1111. the list is generated when you need a folder name the first time (as
  1112. with `o' (`mh-refile-msg')).  If you have a lot of folders and you have
  1113. `mh-recursive-folders' set, this could take a while, which is why it's
  1114. nice to do the folder collection in the background.
  1115.  
  1116.    The function `mh-default-folder-for-message-function' is used by `o'
  1117. (`mh-refile-msg') and `C-c C-f C-f' (`mh-to-fcc') to generate a default
  1118. folder.  The generated folder name should be a string with a `+' before
  1119. it.  For each of my correspondents, I use the same name for both an
  1120. alias and a folder.  So, I wrote a function that takes the address in
  1121. the `From:' header field, finds it in my alias file, and returns the
  1122. alias, which is used as a default folder name.  This is the most
  1123. complicated example given here, and it demonstrates several features of
  1124. Emacs Lisp programming.  You should be able to drop this into
  1125. `~/.emacs', however.  If you use this to store messages in a subfolder
  1126. of your Mail directory, you can modify the line that starts `(format
  1127. +%s...'  and insert your subfolder after the folder symbol `+'.
  1128.  
  1129.      Creating useful default folder for refiling via mh-default-folder-for-message-function
  1130.      
  1131.      (defun my-mh-folder-from-address ()
  1132.        "Determine folder name from address.
  1133.      Takes the address in the From: header field, and returns its corresponding
  1134.      alias from the user's personal aliases file. Returns `nil' if the address
  1135.      was not found."
  1136.        (require 'rfc822)                         ; for the rfc822 functions
  1137.        (search-forward-regexp "^From: \\(.*\\)") ; grab header field contents
  1138.        (save-excursion                     ; save state
  1139.          (let ((addr (car (rfc822-addresses  ; get address
  1140.                            (buffer-substring (match-beginning 1)
  1141.                                              (match-end 1)))))
  1142.                (buffer (get-buffer-create " *temp*")) ; set local variables
  1143.                folder)
  1144.            (set-buffer buffer)             ; jump to temporary buffer
  1145.            (unwind-protect                 ; run kill-buffer when done
  1146.                (progn                      ; function grouping construct
  1147.                  (insert-file-contents (expand-file-name "aliases"
  1148.                                                          mh-user-path))
  1149.                  (goto-char (point-min))   ; grab aliases file and go to start
  1150.                  (setq folder
  1151.                        ;; Search for the given address, even commented-out
  1152.                        ;; addresses are found!
  1153.                        ;; The function search-forward-regexp sets values that are
  1154.                        ;; later used by match-beginning and match-end.
  1155.                        (if (search-forward-regexp (format "^;*\\(.*\\):.*%s"
  1156.                                                           addr) nil t)
  1157.                            ;; NOTE WELL: this is what the return value looks like.
  1158.                            ;; You can modify the format string to match your own
  1159.                            ;; Mail hierarchy.
  1160.                            (format "+%s" (buffer-substring (match-beginning 1)
  1161.                                                            (match-end 1))))))
  1162.              (kill-buffer buffer))          ; get rid of our temporary buffer
  1163.            folder)))                        ; function's return value
  1164.      
  1165.      (setq mh-default-folder-for-message-function 'my-mh-folder-from-address)
  1166.  
  1167.    The hook `mh-refile-msg-hook' is called after a message is marked to
  1168. be refiled.
  1169.  
  1170.    The variable `mh-sortm-args' holds extra arguments to pass on to the
  1171. `sortm' command.  Note: this variable is only consulted when a prefix
  1172. argument is given to `M-x mh-sort-folder'.  It is used to override any
  1173. arguments given in a `sortm:' entry in your MH profile
  1174. (`~/.mh_profile').
  1175.  
  1176. * Menu:
  1177.  
  1178. * Customizing Scan Line Formats::
  1179.  
  1180.